import { createFileChunk } from "../utils/createFileChunk";

onmessage = async e => {
    const { file, chunkSize, startChunkIndex, endChunkIndex } = e.data;
    // 异步进行文件编码
    const promises = [];
    for (let i = startChunkIndex; i < endChunkIndex; i++) {
        promises.push(createFileChunk(file, i, chunkSize));
    }
    const chunks = await Promise.all(promises);
    // 发送编码结果
    postMessage(chunks);
};